package com.linkhub.oms.dao.mpservice.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkhub.oms.common.enums.mp.DataStatusEnum;
import com.linkhub.oms.common.enums.mp.TransactionTypeEnum;
import com.linkhub.oms.dao.mapper.UserAccountFlowEntityMapper;
import com.linkhub.oms.dao.mpservice.IUserAccountFlowService;
import com.linkhub.oms.entity.UserAccountFlowEntity;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  * <p>
 *  * 账单列表 服务实现类
 *  * </p>
 * @author Jaycle
 * @version 1.0.0
 * @Description UserAccountFlowServiceImpl.java
 * @createTime 2024/06/29 22:18
 */
@Service
public class UserAccountFlowServiceImpl extends ServiceImpl<UserAccountFlowEntityMapper, UserAccountFlowEntity> implements IUserAccountFlowService {


    @Override
    public List<UserAccountFlowEntity> getExpendFee( String userId, String startDate, String endDate ) {
        return lambdaQuery()
                .eq(UserAccountFlowEntity::getUserId, userId)
                .ge(UserAccountFlowEntity::getCreatedTime, startDate)
                .lt(UserAccountFlowEntity::getCreatedTime, endDate)
                .eq(UserAccountFlowEntity::getTransactionType, TransactionTypeEnum.PAY)
                .eq(UserAccountFlowEntity::getDataStatus, DataStatusEnum.ENABLE)
                .list();
    }

    @Override
    public UserAccountFlowEntity queryByTransactionId(String transactionId) {
        return lambdaQuery()
                .eq(UserAccountFlowEntity::getTransactionId, transactionId)
                .one();
    }

}
